//
//  NSObject+BTNIMGLAB.m
//  SG
//
//  Created by FISH on 2018/4/21.
//  Copyright © 2018年 yimindai. All rights reserved.
//

#import "NSObject+BTNIMGLAB.h"

@implementation NSObject (BTNIMGLAB)

- (void)setButtonImageUpLableDown:(UIButton*)button AndCGFloat:(CGFloat)Height
{
    if(Height > 0)
    {
        CGFloat offset = Height;
        button.titleEdgeInsets = UIEdgeInsetsMake(0, -button.imageView.frame.size.width, -button.imageView.frame.size.height-offset/2, 0);
        // button.imageEdgeInsets = UIEdgeInsetsMake(-button.titleLabel.frame.size.height-offset/2, 0, 0, -button.titleLabel.frame.size.width);
        // 由于iOS8中titleLabel的size为0，用上面这样设置有问题，修改一下即可
        button.imageEdgeInsets = UIEdgeInsetsMake(-button.titleLabel.intrinsicContentSize.height-offset/2, 0, 0, -button.titleLabel.intrinsicContentSize.width);
    }
    else
    {
        button.titleEdgeInsets = UIEdgeInsetsMake(0, -button.imageView.frame.size.width, -button.imageView.frame.size.height, 0);
        button.imageEdgeInsets = UIEdgeInsetsMake(-button.titleLabel.intrinsicContentSize.height, 0, 0, -button.titleLabel.intrinsicContentSize.width);
    }
}

- (void)setButtonImageLeftLableRight:(UIButton*)button  
{
    button.imageEdgeInsets = UIEdgeInsetsMake(0, -8, 0, 8);
    button.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
}

@end
